﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AlmaDatabase;

namespace Alma.Models
{
    public class ProductCriterionModel
    {
        public long ID_Product { get; set; }
        public long ID_Criterion { get; set; }
        public string Name_Product { get; set; }
        public string Name_Criterion { get; set; }
        public string Value { get; set; }

        public ProductCriterionModel()
        {
        }

        public ProductCriterionModel(ProductCriterion prod)
        {
            ID_Product = prod.ID_Product;
            ID_Criterion = prod.ID_Criterion;
            Value = prod.Value;
            using (var context = new AlmaDBEntities())
            {
                var product = from products in context.Products
                              where products.ID == ID_Product
                              select products;
                Name_Product = product.First().Name;
                var criterion = from criterions in context.Criteria
                                where criterions.ID == ID_Criterion
                                select criterions;
                Name_Criterion = criterion.First().Name;
            };
        }
    }

    public class ProductCriterionListModel
    {
        public List<ProductCriterionModel> List { get; set; }

        public ProductCriterionListModel()
        {
            List = new List<ProductCriterionModel>();
        }
    }
}